﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using MJM.REDES.EN;
using MJM.CBD.Conn;


namespace MJM.REDES.AD
{
    public static class FiltroAD
    {
        public static int Insertar(FiltroEN obj)
        {
            SqlConnection conn = new SqlConnection(Cadena.GetCadenaPadron());
            SqlCommand cmd = new SqlCommand("sp_i_T_MAES_FILRED_Insertar",conn);
            cmd.CommandType = CommandType.StoredProcedure;
            int codigo = 1;
            try
            {
                cmd.Parameters.Add(new SqlParameter("@vFILRED_chINSFIL", obj.Comando));
                cmd.Parameters.Add(new SqlParameter("@vFILRED_chDESFIL", obj.Descripcion));
                cmd.Parameters.Add(new SqlParameter("@vFILRED_chNOMFIL", obj.Nombre));
                cmd.Parameters.Add(new SqlParameter("@vFILRED_inFLAELI", obj.ID));
                cmd.Connection.Open();
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                conn.Dispose();
            }
            catch(Exception ex)
            {
                cmd.Dispose();
                conn.Dispose();
                codigo = 0;
            }

            return codigo;
        }
    }
}
